package com.finalist.dao.impl;

import java.util.List;

import javax.persistence.FlushModeType;
import javax.persistence.NoResultException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.finalist.dao.WinPeopleInfoDao;
import com.finalist.entity.MemberAttribute;
import com.finalist.entity.Product;
import com.finalist.entity.WinPeopleInfo;
@Repository("winPeopleInfoDaoImpl")
public class WinPeopleInfoDaoImpl extends BaseDaoImpl<WinPeopleInfo, Long> implements WinPeopleInfoDao {
    private static final Log log = LogFactory.getLog(WinPeopleInfoDaoImpl.class);
	public void saveWinPeopleInfo(WinPeopleInfo winPeopleInfo) {
		
	}

	@Override
	public WinPeopleInfo findByToken(String token) {
		if (token == null) {
			return null;
		}
		String jpql = "select winPeopleInfo from WinPeopleInfo winPeopleInfo where token = :token";
		try {
			return entityManager.createQuery(jpql, WinPeopleInfo.class).setFlushMode(FlushModeType.COMMIT).setParameter("token", token).getSingleResult();
		} catch (Exception e) {
        	e.printStackTrace();
        	log.error(e.toString());
			return null;
		}
	}


	@Override
	public List<WinPeopleInfo> findByNotSubmit() {
		String jpql = "select memberAttribute from WinPeopleInfo memberAttribute where memberAttribute.isSubmit = 'false' ";
		return entityManager.createQuery(jpql, WinPeopleInfo.class).setFlushMode(FlushModeType.COMMIT).getResultList();
		
	}
	
}
